#ifndef COLORMAKER_H
#define COLORMAKER_H

#include <QObject>
#include <QColor>
#include <QtQml>
class ColorMaker : public QObject
{
    Q_OBJECT
    Q_ENUMS(GenerateAlgorithm)
    Q_PROPERTY(QColor color READ color WRITE set_color NOTIFY color_changed)
    Q_PROPERTY(QColor timeColor READ time_color)

public:
    explicit ColorMaker(QObject *parent = 0);
    ~ColorMaker();

    enum GenerateAlgorithm {
        RandomRGB,
        RandomRed,
        RandomGreen,
        RandomBlue,
        LinearIncrease
    };

    QColor color() const;
    void set_color(const QColor &color);
    QColor time_color() const;

    Q_INVOKABLE GenerateAlgorithm algorithm() const;
    Q_INVOKABLE void set_algorithm(GenerateAlgorithm algorithm);

signals:
    void color_changed(const QColor &color);
    void current_time(const QString &time);

public slots:
    void start();
    void stop();

protected:
    void timerEvent(QTimerEvent *e);

private:
    GenerateAlgorithm m_algorithm;
    QColor m_currentColor;
    int m_colorTimer;
};

#endif // COLORMAKER_H
